import React from 'react';

import './App.css';
import Logo from "./components/logo/Logo";
import { WhiteSpace, WingBlank, Button } from 'antd-mobile';


// 使用redux要用connect将redux中的state和fn映射到此组件的props上
import { connect } from "react-redux";
// redux中的方法regist 用connect关联 到Regist组件 
import { resetPath } from './redux/reducers/user.reducer.js';

class App extends React.Component{
  constructor(props){
    super(props);
    this.loginClick = this.loginClick.bind(this);
    this.toRegistClick = this.toRegistClick.bind(this);
  }

  componentDidMount(){
    this.props.resetPath();
  }

  loginClick(){
      this.props.history.push('/login');
  }
  toRegistClick(){
      this.props.history.push('/regist');
  }
  render(){
    return (
      <div className="App">
        <Logo></Logo>
        <WingBlank>
            <WhiteSpace></WhiteSpace>
            <Button type="primary" onClick={this.loginClick} className="login_btn">登 录</Button>
            <WhiteSpace/>
            <Button type="primary" onClick={this.toRegistClick}>注 册</Button>
        </WingBlank>
      </div>
    );
  }
}

export default connect(
  state => state,
  { resetPath }
)(App)
